package com.wanczy.dao.proxy;

import java.sql.Connection;
import java.util.List;

import org.apache.commons.dbutils.DbUtils;

import com.wanczy.dao.RoleMenuOpDAO;
import com.wanczy.dao.impl.RoleMenuOpDAOImpl;
import com.wanczy.pojo.MenuTable;
import com.wanczy.pojo.RoleMenuTable;
import com.wanczy.pojo.RoleTable;
import com.wanczy.util.GetDBConnection;

public class RoleMenuOpDAOProxy implements RoleMenuOpDAO {
	public Connection conn = null;
	public RoleMenuOpDAOImpl impl = null;
	public RoleMenuOpDAOProxy() {
		try {
			this.conn =  GetDBConnection.getConnection();//ȡ�����ݿ������
			this.impl = new RoleMenuOpDAOImpl(this.conn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Override
	public List<RoleMenuTable> findByRoleName(int roleId) {
		List<RoleMenuTable> list = this.impl.findByRoleName(roleId);
		DbUtils.closeQuietly(conn);
		return list;
	}
	@Override
	public List<RoleTable> find() {
		List<RoleTable> list = this.impl.find();
		DbUtils.closeQuietly(conn);
		return list;
	}
	@Override
	public List<MenuTable> findMenu() {
		List<MenuTable> list = this.impl.findMenu();
		DbUtils.closeQuietly(conn);
		return list;
	}
	@Override
	public boolean doDel(int roleId) {
		boolean flag = this.impl.doDel(roleId);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}
	@Override
	public boolean doIns(int roleMenuId, int menuId, int roleId) {
		boolean flag = this.impl.doIns(roleMenuId, menuId, roleId);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}

}
